const SQLite3 = require('./node_sqlite3')

async function main() {
    const db = new SQLite3('./test.db')  // or file.sqlite3
    await db.open()  // must open first

    //await db.run("CREATE TABLE users (id INT PRIMARY KEY, name TEXT)")
    //await db.run("INSERT INTO users (id, name) VALUES (1, 'foo')")

    var rows = await db.all("SELECT id, name FROM users WHERE id = ?", [1])  // params must be iterable
    rows.forEach(row => console.log(row.id, row.name))


    //await db.run("INSERT INTO users (id, name) VALUES (1, 'foo')")
    await db.each("SELECT * FROM users", [], function(row) {
        console.log(row)
    })

    await db.close()
}

main()
